<template>
  <!-- ---------------------------------------------表单 -->
    <el-card>
      <el-form
        :model="ruleForm"
        :rules="rules"
        :inline="true"
        ref="ruleForm"
        label-width="90px"
        class="demo-ruleForm"
      >
        <el-form-item label="业务品种" prop="serviceType">
          <el-select v-model="ruleForm.serviceType" placeholder="请选择业务品种" style="width: 170px;">
            <el-option label="融资性担保" value="1"></el-option>
            <el-option label="非融资性担保" value="2"></el-option>
            <el-option label="综合授信" value="3"></el-option>
            <el-option label="委托担保" value="4"></el-option>
            <el-option label="再担保业务" value="5"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="资料类型" prop="mateType">
          <el-select v-model="ruleForm.mateType" placeholder="请选择资料类型" style="width: 170px;">
            <el-option label="基础材料" value="1"></el-option>
            <el-option label="反担保材料" value="2"></el-option>
            <el-option label="法律文物" value="3"></el-option>
            <el-option label="保后材料" value="4"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="资料编号" prop="mateCode">
          <el-input v-model="ruleForm.mateCode" disabled style="width: 170px;"></el-input>
        </el-form-item>
        <el-form-item label="是否公用" prop="isUse">
          <el-switch v-model="ruleForm.isUse" style="width: 170px;"></el-switch>
        </el-form-item>
        <el-form-item label="资料名称" prop="mateName">
          <el-input v-model="ruleForm.mateName" style="width: 170px;"></el-input>
        </el-form-item>
        <el-form-item label="资料等级" prop="mateLevel">
          <el-select v-model="ruleForm.mateLevel" placeholder="请选择资料等级" style="width: 170px;">
            <el-option label="一级" value="1"></el-option>
            <el-option label="二级" value="2"></el-option>
            <el-option label="三级" value="3"></el-option>
            <el-option label="四级" value="4"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="资料类别" prop="mateCategory">
          <el-select v-model="ruleForm.mateCategory" placeholder="请选择资料类别" style="width: 170px;">
            <el-option label="企业材料" value="1"></el-option>
            <el-option label="相关报告" value="2"></el-option>
            <el-option label="个人反担保" value="3"></el-option>
            <el-option label="企业反担保" value="4"></el-option>
            <el-option label="抵质押物" value="5"></el-option>
            <el-option label="合同" value="6"></el-option>
            <el-option label="保后报告" value="7"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="银行" prop="bankName" style="display: flex;">
          <el-input type="textarea" v-model="ruleForm.bankName" style="width: 445px;"></el-input>
        </el-form-item>
        <el-form-item label="备注" prop="remarks" style="display: flex;">
          <el-input type="textarea" v-model="ruleForm.remarks" style="width: 445px;"></el-input>
        </el-form-item>
        <el-form-item style="display: block; text-align: right;">
          <el-button type="primary" @click="submitForm('ruleForm')" :loading="btnLoad">提交</el-button>
          <el-button @click="resetForm('ruleForm')">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>
</template>

<script>
    export default {
        data() {
            return {
              btnLoad: false,
              ruleForm: {
              },
              rules: {
                serviceType: [{
                    required: true,
                    message: "请选择业务品种",
                    trigger: "change"
                }],
                mateType: [{
                    required: true,
                    message: "请选择资料类型",
                    trigger: "change"
                }],
                mateName: [{
                    required: true,
                    message: "请输入资料名称",
                    trigger: "blur"
                }],
                mateCategory: [{
                    required: true,
                    message: "请选择资料类别",
                    trigger: "change"
                }],
              },
            };
        },
        mounted() {
        },
        methods: {
          submitForm(formName) {
            let that = this;
            this.$refs[formName].validate(valid => {
                if (valid) {
                  
                  // true '1', false '0'
                  that.ruleForm.isUse = that.ruleForm.isUse ? '1' : '0';
                  that.save(that.ruleForm, that.returnFlag);
                } else {
                    return false;
                }
            });
          },
          resetForm(formName) {
            this.$refs[formName].resetFields();
          },
          init() {
      
          },
          save(params) {
            this.btnLoad = true;
            this.$api.formPost("/api/biz/baseMaterial/doSave", params)
            .then(res => {
              let flag = false;
              this.btnLoad = false;
              if (res.retHead.code === "0000000") {
                flag = true;
                this.$message({
                  message: "提交成功！",
                  type: "success"
                });
                this.$parent.$parent.init();
                this.$parent.$parent.dialogVisible1 = false;
              } else {
                this.$message({
                  message: "提交失败！",
                  type: res.retHead.message
                });
              }
            });
            
          },

        }
    };
</script>
<style lang='scss' scoped>
</style>